package com.xiaohan.turtlesoup.controller;

import com.xiaohan.turtlesoup.domain.ChatRoom;
import com.xiaohan.turtlesoup.service.ChatService;
import io.swagger.v3.oas.annotations.links.Link;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: TurtleSoup
 * @description: 对话控制类
 * @author: 韩小豪
 * @create: 2025-03-22 18:37
 **/

@RestController
@RequestMapping("/chat")
public class ChatController {

	@Resource
	private ChatService chatService;

	/**
	 * 与AI对话
	 *
	 * @param roomId  房间id
	 * @param message 用户输入的消息
	 * @return
	 */
	@PostMapping("/{roomId}/send")
	public String doChat(@PathVariable Long roomId, @RequestParam String message) {
		return chatService.doChat(roomId, message);
	}

	/**
	 * 获取当前房间的所有聊天记录
	 *
	 * @param roomId 房间id
	 * @return ChatRooms 放回的房间对象
	 */
	@GetMapping("/{roomId}/rooms")
	public List<ChatRoom> getChatRoomList(@PathVariable Long roomId) {
		return chatService.getHistoricalChatRecords(roomId);
	}
}
